/*
 * Минимум на отрезке
 * vim:foldmethod=marker:
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N_MAX 150000
#define K_MAX  10000

#define SWAP_INT(a, b)		(((a) ^ (b)) && ((b) ^= (a) ^= (b), (a) ^= (b)))

struct unit { int value; int index; };

inline void
swap_units(struct unit *a, struct unit *b)
{
	struct unit T;
	T  = *a;
	*a = *b;
	*b =  T;
}

void
Heap_sort__sift_down(struct unit *array, int *heap_index, int start, int end)
{
	int parent = start,
	    child,
	    swap;

	while (parent * 2 + 1 <= end) {
		child = parent * 2 + 1;
		swap = parent;

		if (array[swap].value > array[child].value) /* rev */
			swap = child;

		if (child+1 <= end && array[swap].value > array[child+1].value) /* rev */
			swap = child+1;

		if (swap != parent) {
			swap_units(&array[parent], &array[swap]);
			SWAP_INT(heap_index[parent], heap_index[swap]);
			parent = swap;
		} else {
			return;
		}
	}
}

void
Heap_sort__sift_up(struct unit *array, int *heap_index, int start, int end)
{
	int child = end,
	    parent = (end - 1) / 2;

        while (child > start) {
		if (array[(child - 1) / 2].value > array[child].value) { /* rev */
			swap_units(&array[parent], &array[child]);
			SWAP_INT(heap_index[parent], heap_index[child]);
			child = parent--;
			parent /= 2;
		} else
			return;
	}
}

void
Heap_sort__heapify(struct unit *array, int *heap_index, int size)
{
	int start = size / 2 - 1;

	while (start >= 0) {
		Heap_sort__sift_down(array, heap_index, start--, size - 1);
	}
}

void
Heap_sort(struct unit *array, int *heap_index, int size)
{
	int end = size - 1;

	Heap_sort__heapify(array, heap_index, size);

	while (end > 0) {
		swap_units(&array[end], &array[0]);
		SWAP_INT(heap_index[end], heap_index[0]);

		Heap_sort__sift_down(array, heap_index, 0, --end);
	}
}

void
mkheap(int *seq, struct unit *heap, int *heap_index, int end)
{
	register int i = 0;

	for (i = 0; i < end; ++i) {
		heap[i].value = seq[i];
		heap[i].index = i;
		heap_index[i] = i;
	}
	Heap_sort__heapify(heap, heap_index, end);
}

static void
debug(const int *seq, const struct unit *heap,
		const int *heap_index, const int n, const int i_, const int k_)
{
	register int i;

	fputs("D: ", stderr);
	for (i = 0; i < n; i++)
		(void) fprintf(stderr, "%d%s", seq[i], i+1!=n ?" ":"\n");

	fputs("D: ", stderr);
	for (i = 0; i < k_; i++)
		(void) fprintf(stderr, "{%d,%d}%s", heap[i].value,
				heap[i].index, i+1!=k_?" ":"\n");

	fputs("D: WINDOW: ", stderr);
	for (i = i_; i < i_ + k_; i++)
		(void) fprintf(stderr, "%d%s", seq[i], i+1!=i_+k_?" ":"\n");
	putc('\n', stderr);
}

/*
 *     0   1   2   3   4   5   6
 *   +---+---+---+---+---+---+---+-
 *   | a | b | c | d | e | f | g | ..  <- seq
 *   +---+---+---+---+---+---+---+-
 *
 *
 *     0   1   2   3   4   5   6
 *   +---+---+---+---+---+---+---+-
 *   | ? | ? | 2 | 0 | 3 | 1 | ? | ..  <- heap_index
 *   +---+---+---+---+---+---+---+      start=2 end=5 i=1 k=4
 *
 *
 *     0   1   2   3     <- heap_index k=4
 *   +---+---+---+---+
 *   | d | f | c | e |   <- unit.value
 *   | 3 | 5 | 2 | 4 |          .index
 *   +---+---+---+---+
 *
 *  d <= f <= e
 */

int
main(void)
{
	static int	seq[N_MAX];
	static struct unit heap[K_MAX];
	static int	heap_index[N_MAX]; /* Where elements from 'seq' are
					      stored in 'heap'.
					       seq[i] --> heap[j]
					    */
	int		n, k;
	register int	i = 0;

	(void) freopen("minimum.in", "r", stdin);
	(void) freopen("minimum.out", "w", stdout);

	(void) scanf("%d%d", &n, &k);
	for (i = 0; i < n; i++)
		(void) scanf("%d", &seq[i]);

	mkheap(seq, heap, heap_index, k);
	(void) printf("%d\n", heap[0].value);
	for (i = 1; i + k < n; i++) {
		heap_index[i+k-1] = heap_index[i-1];
		heap[heap_index[i+k-1]].value = seq[i+k-1];
		heap[heap_index[i+k-1]].index = i+k-1;

		//if (heap[heap_index[i+k-1]].value < heap[ (heap_index[i+k-1] - 1) / 2].value)
			Heap_sort__sift_up(heap, heap_index, 0, heap_index[i+k-1]);
		//else
			Heap_sort__sift_down(heap, heap_index, heap_index[i+k-1], k-1);

		if (i <= 20)
			debug(seq, heap, heap_index, (n > 20) ? 20 : n, i, k);

		(void) printf("%d\n", heap[0].value);
	}
	return 0;
}
